<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <script src="../js/bootstrap.min.js"></script>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>预约管理<small>检查项管理</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>预约管理</el-breadcrumb-item>
            <el-breadcrumb-item>检查项管理</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <template>
                    <div class="block">
                        <span class="demonstration">时间</span>
                        <el-date-picker
                                v-model="value1"
                                type="datetime"
                                placeholder="起始时间">
                        </el-date-picker>-
                        <el-date-picker
                                v-model="value2"
                                type="datetime"
                                placeholder="结束时间">
                        </el-date-picker>
                        <el-input placeholder="角色名" v-model="pagination.queryString" style="width: 200px;" class="filter-item"></el-input>
                        <el-button @click="_findPage()" class="dalfBut">查询</el-button>
                    </div>
                </template>

            </div>
            <el-table size="small" current-row-key="id" :data="logmessage" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="method" label="操作方法名" align="center"></el-table-column>
                <el-table-column prop="date" label="时间" align="center"></el-table-column>
                <el-table-column prop="user" label="角色" align="center"></el-table-column>
                <el-table-column prop="classname" label="操作的类名" align="center"></el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    var pre = new Date();
    pre.setDate(pre.getDate()-1);
    this.value1 = pre;
    this.value2 = new Date();
    var vue = new Vue({
        el: '#app',
        data: {
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize: 10,//每页显示的记录数
                total: 0,//总记录数
                queryString: null//查询条件
            },

            value1: "",
            value2: "",


            logmessage: [],//当前页要展示的分页列表数据

            backendUrl:"http://localhost:82"
        },
        //钩子函数，VUE对象初始化完成后自动执行
        created() {

            this.findPage();
        },
        methods: {

            _findPage(){
                if(this.pagination.queryString!= null && this.pagination.queryString.length > 0){
                    //如果条件不为null，则查询第一页
                    this.pagination.currentPage = 1;
                }

                  this.findPage();

            }
            ,
            //1. 分装分页参数
            //2. 发送请求，查询数据
            //3. 列表数据需要在表格中展示， 分页组件实现
            //分页查询
            findPage() {

                var T1=this.formatDate(this.value1.getFullYear(),this.value1.getMonth()+1,this.value1.getDate(),this.value1.getHours(),this.value1.getMinutes(),this.value1.getSeconds());
                var T2=this.formatDate(this.value2.getFullYear(),this.value2.getMonth()+1,this.value2.getDate(),this.value2.getHours(),this.value2.getMinutes(),this.value2.getSeconds());
                //1. 分装分页参数
                var param = {
                    currentPage: this.pagination.currentPage,
                    pageSize: this.pagination.pageSize,
                    queryString: this.pagination.queryString,
                };
                //2. 发送请求，查询数据
                axios.defaults.withCredentials = true;
                axios.post(this.backendUrl+ "/logcontroller/findLog.do?T1="+T1+"&T2="+T2, param).then((response)=>{
                    //3. 列表数据需要在0表格中展示， 分页组件实现
                    this.logmessage = response.data.rows;
                    this.pagination.total = response.data.total;
                    this.value1="";
                    this.value2="";
                }).catch((err)=>{
                    this.showMessage(err)
                });

            },
            //切换页码
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;
                this.findPage();
            },
            formatDate: function (year, month, day,hour,minute,second) {
                var y = year;
                var m = month;
                if (m < 10) m = "0" + m;
                var d = day;
                if (d < 10) d = "0" + d;
                var h = hour;
                if (h < 10) h = "0" + h;
                var M = minute;
                if (M < 10) M = "0" + M;
                var s = second;
                if (s < 10) s = "0" + s;
                return y + "-" + m + "-" + d+ " " +h + ":" + M +":" +s
            }
        }
    })
</script>

</html>